VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{753FEE6F-A545-4EAA-AAC8-87512ED29F21}#3.0#0"; "ccrpDtp6.ocx"
Object = "{8D650141-6025-11D1-BC40-0000C042AEC0}#3.0#0"; "ssdw3b32.ocx"
Begin VB.Form frmCierreDia 
   BackColor       =   &H00FFFFFF&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Cierre Dia"
   ClientHeight    =   7950
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   8055
   Icon            =   "frmCierreDia.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   7950
   ScaleWidth      =   8055
   Begin VB.Frame Frame3 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Ingresos"
      Height          =   855
      Left            =   4080
      TabIndex        =   22
      Top             =   360
      Width           =   3855
      Begin VB.TextBox txtCoop 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         Enabled         =   0   'False
         Height          =   315
         Left            =   2280
         TabIndex        =   24
         Text            =   "0,00"
         Top             =   360
         Width           =   1365
      End
      Begin VB.TextBox txtProf 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         Enabled         =   0   'False
         Height          =   315
         Left            =   840
         TabIndex        =   23
         Text            =   "0,00"
         Top             =   360
         Width           =   1365
      End
      Begin VB.Label Label2 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Cooperativa:"
         Height          =   255
         Left            =   2520
         TabIndex        =   26
         Top             =   120
         Width           =   975
      End
      Begin VB.Label Label4 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Profesional:"
         Height          =   255
         Left            =   840
         TabIndex        =   25
         Top             =   120
         Width           =   975
      End
   End
   Begin VB.Frame Frame2 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Dia"
      Height          =   855
      Left            =   120
      TabIndex        =   17
      Top             =   360
      Width           =   3495
      Begin VB.CommandButton cmdVer 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         Caption         =   "Ver dia"
         Height          =   270
         Left            =   2160
         MaskColor       =   &H00FFFFFF&
         Style           =   1  'Graphical
         TabIndex        =   1
         Top             =   360
         Width           =   1140
      End
      Begin CCRPDTP6.ccrpDtp cmpDia 
         Height          =   315
         Left            =   240
         TabIndex        =   0
         Top             =   360
         Width           =   1575
         _ExtentX        =   2778
         _ExtentY        =   556
         CustomFormat    =   "dd/MM/yyyy"
         Min             =   36526
         Max             =   219512
         CCRPVer         =   1
         Var             =   "frmCierreDia.frx":08CA
         XD              =   "frmCierreDia.frx":08FE
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "20/07/2010"
      End
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00FFFFFF&
      Height          =   2415
      Left            =   120
      TabIndex        =   10
      Top             =   1200
      Width           =   7815
      Begin VB.TextBox txtOrd 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         Enabled         =   0   'False
         Height          =   315
         Left            =   3360
         TabIndex        =   20
         Text            =   "0,00"
         Top             =   480
         Width           =   1245
      End
      Begin VB.TextBox txtFon 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         Enabled         =   0   'False
         Height          =   315
         Left            =   6360
         TabIndex        =   18
         Text            =   "0,00"
         Top             =   480
         Width           =   1275
      End
      Begin VB.TextBox txObs 
         Appearance      =   0  'Flat
         Enabled         =   0   'False
         Height          =   315
         Left            =   120
         MaxLength       =   190
         TabIndex        =   7
         Top             =   1920
         Width           =   7500
      End
      Begin VB.ComboBox cmbTipo 
         Enabled         =   0   'False
         Height          =   315
         ItemData        =   "frmCierreDia.frx":095A
         Left            =   2040
         List            =   "frmCierreDia.frx":0965
         Style           =   2  'Dropdown List
         TabIndex        =   5
         Top             =   1320
         Width           =   1455
      End
      Begin VB.TextBox txtAjus 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         Enabled         =   0   'False
         Height          =   315
         Left            =   120
         MaxLength       =   12
         TabIndex        =   4
         Text            =   "0,00"
         Top             =   1320
         Width           =   1620
      End
      Begin VB.TextBox txtIng 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         Enabled         =   0   'False
         Height          =   315
         Left            =   360
         TabIndex        =   2
         Text            =   "0,00"
         Top             =   480
         Width           =   1245
      End
      Begin VB.TextBox txtEgr 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         Enabled         =   0   'False
         Height          =   315
         Left            =   1680
         TabIndex        =   3
         Text            =   "0,00"
         Top             =   480
         Width           =   1245
      End
      Begin VB.TextBox txtNeto 
         Alignment       =   1  'Right Justify
         Appearance      =   0  'Flat
         Enabled         =   0   'False
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         Left            =   5520
         TabIndex        =   6
         Text            =   "0,00"
         Top             =   1320
         Width           =   2055
      End
      Begin VB.Label Label10 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Ingreso Ordenes:"
         Height          =   255
         Left            =   3360
         TabIndex        =   21
         Top             =   240
         Width           =   1215
      End
      Begin VB.Label Label9 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Fondo Fijo:"
         Height          =   255
         Left            =   6360
         TabIndex        =   19
         Top             =   240
         Width           =   1095
      End
      Begin VB.Label Label8 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Observacion:"
         Height          =   255
         Left            =   120
         TabIndex        =   16
         Top             =   1680
         Width           =   1455
      End
      Begin VB.Label Label1 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Tipo:"
         Height          =   255
         Left            =   2040
         TabIndex        =   15
         Top             =   1080
         Width           =   615
      End
      Begin VB.Label Label3 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Ajuste:"
         Height          =   255
         Left            =   120
         TabIndex        =   14
         Top             =   1080
         Width           =   615
      End
      Begin VB.Label Label5 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Ingreso Efectivo:"
         Height          =   255
         Left            =   360
         TabIndex        =   13
         Top             =   240
         Width           =   1215
      End
      Begin VB.Label Label6 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Egreso Efectivo:"
         Height          =   255
         Left            =   1680
         TabIndex        =   12
         Top             =   240
         Width           =   1215
      End
      Begin VB.Label Label7 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Neto:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   5520
         TabIndex        =   11
         Top             =   1080
         Width           =   1455
      End
      Begin VB.Line Line1 
         BorderColor     =   &H00C0C0C0&
         X1              =   120
         X2              =   7680
         Y1              =   960
         Y2              =   960
      End
   End
   Begin MSComctlLib.ImageList ImageList1 
      Left            =   2280
      Top             =   0
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   16
      ImageHeight     =   16
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   11
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCierreDia.frx":0976
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCierreDia.frx":0F10
            Key             =   ""
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCierreDia.frx":14AA
            Key             =   ""
         EndProperty
         BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCierreDia.frx":1A44
            Key             =   ""
         EndProperty
         BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCierreDia.frx":1FDE
            Key             =   ""
         EndProperty
         BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCierreDia.frx":2578
            Key             =   ""
         EndProperty
         BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCierreDia.frx":2B12
            Key             =   ""
         EndProperty
         BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCierreDia.frx":30AC
            Key             =   ""
         EndProperty
         BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCierreDia.frx":3646
            Key             =   ""
         EndProperty
         BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCierreDia.frx":3BE0
            Key             =   ""
         EndProperty
         BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmCierreDia.frx":417A
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin SSDataWidgets_B.SSDBGrid Grilla 
      Height          =   4095
      Left            =   120
      TabIndex        =   8
      Top             =   3720
      Width           =   7815
      _Version        =   196616
      DataMode        =   2
      Col.Count       =   6
      BevelColorFace  =   16777215
      AllowUpdate     =   0   'False
      RowSelectionStyle=   2
      AllowRowSizing  =   0   'False
      AllowGroupSizing=   0   'False
      AllowGroupMoving=   0   'False
      AllowGroupSwapping=   0   'False
      AllowGroupShrinking=   0   'False
      AllowDragDrop   =   0   'False
      SelectTypeCol   =   0
      SelectTypeRow   =   1
      BackColorEven   =   12648447
      BackColorOdd    =   12640511
      RowHeight       =   423
      Columns.Count   =   6
      Columns(0).Width=   3889
      Columns(0).Caption=   "Usuario"
      Columns(0).Name =   "Usuario"
      Columns(0).CaptionAlignment=   2
      Columns(0).DataField=   "Column 0"
      Columns(0).DataType=   8
      Columns(0).FieldLen=   256
      Columns(1).Width=   1773
      Columns(1).Caption=   "Fondo Fijo"
      Columns(1).Name =   "Fondo Fijo"
      Columns(1).Alignment=   1
      Columns(1).CaptionAlignment=   2
      Columns(1).DataField=   "Column 1"
      Columns(1).DataType=   8
      Columns(1).FieldLen=   256
      Columns(2).Width=   1773
      Columns(2).Caption=   "Efectivo"
      Columns(2).Name =   "Ingreso"
      Columns(2).Alignment=   1
      Columns(2).CaptionAlignment=   2
      Columns(2).DataField=   "Column 2"
      Columns(2).DataType=   8
      Columns(2).FieldLen=   256
      Columns(3).Width=   1773
      Columns(3).Caption=   "Egreso"
      Columns(3).Name =   "Egreso"
      Columns(3).Alignment=   1
      Columns(3).CaptionAlignment=   2
      Columns(3).DataField=   "Column 3"
      Columns(3).DataType=   8
      Columns(3).FieldLen=   256
      Columns(4).Width=   1773
      Columns(4).Caption=   "Ordenes"
      Columns(4).Name =   "Ordenes"
      Columns(4).Alignment=   1
      Columns(4).CaptionAlignment=   2
      Columns(4).DataField=   "Column 4"
      Columns(4).DataType=   8
      Columns(4).FieldLen=   256
      Columns(5).Width=   1773
      Columns(5).Caption=   "Estado"
      Columns(5).Name =   "Estado"
      Columns(5).CaptionAlignment=   2
      Columns(5).DataField=   "Column 5"
      Columns(5).DataType=   8
      Columns(5).FieldLen=   256
      _ExtentX        =   13785
      _ExtentY        =   7223
      _StockProps     =   79
      Caption         =   "Cajas"
      BackColor       =   -2147483643
      Enabled         =   0   'False
      BeginProperty PageFooterFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty PageHeaderFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin MSComctlLib.Toolbar Toolbar1 
      Align           =   1  'Align Top
      Height          =   360
      Left            =   0
      TabIndex        =   9
      Top             =   0
      Width           =   8055
      _ExtentX        =   14208
      _ExtentY        =   635
      ButtonWidth     =   609
      ButtonHeight    =   582
      Appearance      =   1
      Style           =   1
      ImageList       =   "ImageList1"
      _Version        =   393216
      BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
         NumButtons      =   6
         BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Enabled         =   0   'False
            Key             =   "Aceptar"
            Object.ToolTipText     =   "Aceptar (F5)"
            ImageIndex      =   5
         EndProperty
         BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Enabled         =   0   'False
            Key             =   "Cancelar"
            Object.ToolTipText     =   "Cancelar (F8)"
            ImageIndex      =   6
         EndProperty
         BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "Salir"
            Object.ToolTipText     =   "Salir (Esc)"
            ImageIndex      =   11
         EndProperty
         BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
      EndProperty
      BorderStyle     =   1
   End
End
Attribute VB_Name = "frmCierreDia"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim con As New ConBaseDatos, cierre_dia As String
Const decimales As Integer = 2

Private Sub cmbTipo_Change()

CalcularNeto

End Sub

Private Sub cmbTipo_Click()

CalcularNeto

End Sub

Private Sub cmdVer_Click()

If con.ExisteDato("cierres_dia", "fecha", cmpDia.Value, fecha) Then
    If con.ExisteDatos("cierres_dia", "fecha='" & Format(cmpDia.Value, "dd/mm/yyyy") & "' and cerrado=0") Then
        cierre_dia = con.BusDato("cierres_dia", "cierre_dia", "fecha='" & Format(cmpDia.Value, "dd/mm/yyyy") & "' and cerrado=0")
        Toolbar1.Buttons.Item(2).Enabled = True
        Toolbar1.Buttons.Item(3).Enabled = True
        cmpDia.Enabled = False
        cmdVer.Enabled = False
        txtAjus.Enabled = True
        cmbTipo.Enabled = True
        txObs.Enabled = True
        Grilla.Enabled = True
        
        CargarGrilla
                
        con.AbrirRegistros "select isnull(sum(ci.cantidad*(ci.ingreso1+ci.ingreso2)),0) as tot,isnull(sum(ci.cantidad*ci.ingreso1),0) as totprof,isnull(sum(ci.cantidad*ci.ingreso2),0) as totcoop,isnull(sum(ci.cantidad*ci.egreso),0) as totegr from cajas_items ci inner join cajas c on c.caja=ci.caja where day(c.apertura)=" & Day(cmpDia.Value) & " and month(c.apertura)=" & Month(cmpDia.Value) & " and year(c.apertura)=" & Year(cmpDia.Value) & " and ci.estado='Activo' and ci.efectivo=1", Consulta
        If Not con.Registros.EOF Then
            txtProf.Text = FormatoDecimales(con.Registros("totprof"), decimales)
            txtCoop.Text = FormatoDecimales(con.Registros("totcoop"), decimales)
            txtIng.Text = FormatoDecimales(con.Registros("tot"), decimales)
            txtEgr.Text = FormatoDecimales(con.Registros("totegr"), decimales)
        End If
        con.CerrarRegistros
        
        con.AbrirRegistros "select isnull(sum(ci.cantidad*(ci.ingreso1+ci.ingreso2)),0) as tot from cajas_items ci inner join cajas c on c.caja=ci.caja where day(c.apertura)=" & Day(cmpDia.Value) & " and month(c.apertura)=" & Month(cmpDia.Value) & " and year(c.apertura)=" & Year(cmpDia.Value) & " and ci.estado='Activo' and ci.efectivo=0", Consulta
        If Not con.Registros.EOF Then txtOrd.Text = FormatoDecimales(con.Registros("tot"), decimales)
        con.CerrarRegistros
                
        con.AbrirRegistros "select isnull(sum(fondofijo),0) as totfondofijo from cajas where day(apertura)=" & Day(cmpDia.Value) & " and month(apertura)=" & Month(cmpDia.Value) & " and year(apertura)=" & Year(cmpDia.Value), Consulta
        If Not con.Registros.EOF Then txtFon.Text = FormatoDecimales(con.Registros("totfondofijo"), decimales)
        con.CerrarRegistros
        
        cmbTipo.ListIndex = 0
    Else
        cierre_dia = ""
        MsgBox "El dia de cierre (" & Format(cmpDia.Value, "dd/mm/yyyy") & ") esta cerrado", vbCritical, "Datos existentes"
        cmpDia.SetFocus
    End If
Else
    cierre_dia = ""
    MsgBox "En el dia de cierre (" & Format(cmpDia.Value, "dd/mm/yyyy") & ") no se abrio caja", vbCritical, "No hay datos"
    cmpDia.SetFocus
End If

End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)

Select Case KeyCode
    Case 27 'Escape "Salir"
        If Toolbar1.Buttons(4).Enabled Then Toolbar1_ButtonClick Toolbar1.Buttons(4)
        
    Case 112 'F1 "Ayuta"
        frmPrincipal.manual_Click
    
    Case 116 'F5 "Aceptar"
        If Toolbar1.Buttons(2).Enabled Then Toolbar1_ButtonClick Toolbar1.Buttons(2)
 
End Select

End Sub

Private Sub Form_Load()

Abrir Me

End Sub

Private Sub Form_Unload(Cancel As Integer)

If Not Toolbar1.Buttons(4).Enabled Then Cancel = True

End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)

Select Case Button.Key
         
    Case "Salir"
        Unload Me
    
    Case "Aceptar"
        Grabar
        Limpiar
        inHabilitar
        
    Case "Cancelar"
        Limpiar
        inHabilitar
        
End Select

End Sub

Private Sub Grabar()

Dim cajas As Integer, dias As String

'cantidad cajas abiertas
cajas = con.BusDato("cajas", "isnull(count(*),0)", "day(apertura)=" & Day(cmpDia.Value) & " and month(apertura)=" & Month(cmpDia.Value) & " and year(apertura)=" & Year(cmpDia.Value) & " and cierre is null")
'cantidad dias abiertos
con.AbrirRegistros "select fecha from cierres_dia where datediff(day,fecha,'" & Format(cmpDia.Value, "dd/mm/yyyy") & "')>0 and cerrado=0 order by fecha", Consulta
Do While Not con.Registros.EOF
    If dias <> "" Then dias = dias & vbCrLf
    dias = dias & Format(con.Registros("fecha"), "dd/mm/yyyy")
    con.Registros.MoveNext
    DoEvents
Loop
con.CerrarRegistros

If dias <> "" Then
    MsgBox "Hay dias sin cerrar" & vbCrLf & "No puede cerrar este dia(" & Format(cmpDia.Value, "dd/mm/yyyy") & ") sin haber cerrado todos los anteriores" & vbCrLf & dias, vbCritical, "Error de Datos"
ElseIf cajas > 0 Then
    If MsgBox("Hay cajas abiertas: " & cajas & vbCrLf & "Desea cerrarlas", vbInformation + vbYesNo + vbDefaultButton2, "") = vbYes Then
        ControlCaja Format(cmpDia.Value, "dd/mm/yyyy")
        con.ActualizarRegistros "cierres_dia", "observacion,ajuste,tipo,ingreso1,ingreso2,egreso,fondofijo,cerrado,neto,ordenes", "'" & Editar(txObs.Text) & "'," & Replace(txtAjus.Text, ",", ".") & ",'" & cmbTipo.Text & "'," & Replace(txtProf.Text, ",", ".") & "," & Replace(txtCoop.Text, ",", ".") & "," & Replace(txtEgr.Text, ",", ".") & "," & Replace(txtFon.Text, ",", ".") & ",1," & Replace(txtNeto.Text, ",", ".") & "," & Replace(txtOrd.Text, ",", "."), "cierre_dia='" & cierre_dia & "'"
        MsgBox "Dia cerrado: " & cmpDia.Value, vbInformation, ""
    End If
Else
    con.ActualizarRegistros "cierres_dia", "observacion,ajuste,tipo,ingreso1,ingreso2,egreso,fondofijo,cerrado,neto,ordenes", "'" & Editar(txObs.Text) & "'," & Replace(txtAjus.Text, ",", ".") & ",'" & cmbTipo.Text & "'," & Replace(txtProf.Text, ",", ".") & "," & Replace(txtCoop.Text, ",", ".") & "," & Replace(txtEgr.Text, ",", ".") & "," & Replace(txtFon.Text, ",", ".") & ",1," & Replace(txtNeto.Text, ",", ".") & "," & Replace(txtOrd.Text, ",", "."), "cierre_dia='" & cierre_dia & "'"
    MsgBox "Dia cerrado: " & cmpDia.Value, vbInformation, ""
End If

End Sub

Private Sub inHabilitar()

Toolbar1.Buttons.Item(2).Enabled = False
Toolbar1.Buttons.Item(3).Enabled = False
cmpDia.Enabled = True
cmdVer.Enabled = True
txtAjus.Enabled = False
cmbTipo.Enabled = False
txObs.Enabled = False
Grilla.Enabled = False

End Sub

Private Sub Limpiar()

Dim cControl
For Each cControl In Me.Controls
    Select Case Left(cControl.Name, 3)
        Case "cmb"
            cControl.ListIndex = -1
        Case "cmp"
            cControl.Value = Format(Fecha_Server, "dd/mm/yyyy")
        Case "txt"
            cControl.Text = "0.00"
        Case "txO"
            cControl.Text = ""
        Case "Gri"
            Grilla.RemoveAll
    End Select
Next cControl

End Sub

Private Sub CalcularNeto()

If cmbTipo.ListIndex = -1 Then Exit Sub
If txtAjus.Text = "" Then txtAjus.Text = "0,00"
txtNeto.Text = FormatoDecimales(CDbl(txtIng.Text) - CDbl(txtEgr.Text) + (CDbl(txtAjus.Text) * cmbTipo.ItemData(cmbTipo.ListIndex)), decimales)

End Sub

Private Sub CargarGrilla()

Dim dato As String, i As Integer, datoTemp As String

Grilla.RemoveAll
Grilla.Redraw = False
con.AbrirRegistros "select u.nombre as usuario,c.fondofijo,c.ingreso,c.egreso,c.ordenes, case when cierre is null then 'Abierta' else 'Cerrada' end as estado from cajas c left join usuarios u on u.usuario=c.usuario where day(c.apertura)=" & Day(cmpDia.Value) & " and month(c.apertura)=" & Month(cmpDia.Value) & " and year(c.apertura)=" & Year(cmpDia.Value) & " order by u.nombre", Consulta
Do While Not con.Registros.EOF
    dato = ""
    For i = 0 To Grilla.Cols - 1
        datoTemp = ""
        If IsNull(con.Registros(i)) Then
            datoTemp = ""
        Else
            datoTemp = con.Registros(i)
            Select Case con.Registros(i).Name
                Case "fondofijo", "ingreso", "egreso", "ordenes"
                    datoTemp = FormatoDecimales(datoTemp, decimales)
            End Select
        End If
        dato = dato & DesEditar(datoTemp) & vbTab
        DoEvents
    Next i
    Grilla.AddItem dato
    
    con.Registros.MoveNext
    DoEvents
Loop
con.CerrarRegistros
Grilla.Redraw = True

End Sub

Private Sub txtAjus_Change()

CalcularNeto

End Sub

Private Sub txtAjus_GotFocus()

txtAjus.SelStart = 0
txtAjus.SelLength = Len(txtAjus.Text)
txtAjus.BackColor = &HFFFFC0

End Sub

Private Sub txtAjus_KeyPress(KeyAscii As Integer)

'remplazo el . por la ,
If KeyAscii = 46 Then KeyAscii = 44

If InStr(1, txtAjus.Text, ",") <> 0 And KeyAscii = 44 Then
    KeyAscii = 0
    Exit Sub
End If

Select Case KeyAscii
    Case 48 To 57, 44, 8
    
    Case 13
        SendKeys "{TAB}"
        KeyAscii = 0
    
    Case Else
        KeyAscii = 0
End Select

End Sub

Private Sub txtAjus_LostFocus()

If txtAjus.Text = "" Then txtAjus.Text = "0,00"
txtAjus.Text = FormatoDecimales(txtAjus.Text, decimales)
txtAjus.BackColor = &H80000005

End Sub

Private Sub cmbTipo_GotFocus()

cmbTipo.BackColor = &HFFFFC0

End Sub

Private Sub cmbTipo_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then
    SendKeys "{TAB}"
    KeyAscii = 0
End If

End Sub

Private Sub cmbTipo_LostFocus()

cmbTipo.BackColor = &H80000005

End Sub

Private Sub cmpDia_GotFocus()

cmpDia.CalBackColor = &HFFFFC0

End Sub

Private Sub cmpDia_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then
    SendKeys "{TAB}"
    KeyAscii = 0
End If

End Sub

Private Sub cmpDia_LostFocus()

cmpDia.CalBackColor = &H80000005

End Sub

Private Sub txObs_GotFocus()

txObs.SelStart = 0
txObs.SelLength = Len(txObs.Text)
txObs.BackColor = &HFFFFC0

End Sub

Private Sub txObs_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then
    KeyAscii = 0
    If Toolbar1.Buttons(2).Enabled Then Toolbar1_ButtonClick Toolbar1.Buttons(2)
End If

End Sub

Private Sub txObs_LostFocus()

txObs.BackColor = &H80000005

End Sub
